<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<script src="Grid/GridE.js"> </script>
<body>
<input type="button" onclick="loadLocalXML()" value="load by Local XML">
<input type="button" onclick="loadXML()" value="load by XML">
<input type="button" onclick="loadJSON()" value="load by JSON">
<input type="button" onclick="loadFromVar()" value="load var">
	<div id="d2" style="width:100%;">
	<treegrid id="g1" Data_Url="xml/MyData.xml" Layout_Url="xml/MyDef.xml"> </treegrid>  
	</div>
	
<input type="button" onclick="saveAsXML()" value="save by XML">
<input type="button" onclick="saveAsJSON()" value="save by JSON">
	<hr>
	</body>
<script type="text/javascript">

function loadFromVar(){
	var grid1=Grids["g1"];
	//var test='{"Body":[[{"id":"d1","CanDelete":"0","A":"Lucy","B":"998.0","C":"JSON","D":"100"}]]}';
	//var test=null;
	var test=("<Grid><Body><B><I id='d1' CanDelete='0'><U N='A' V='Lucy' /><U N='B' V='998.0' /><U N='C' V='Amazon' /><U N='D' V='100' /></I></B></Body></Grid>");
	grid1.AddDataFromServer(test);
	grid1.Render(); 
}
function loadLocalXML(){
	var grid1=Grids["g1"];
	grid1.Source.Data.Url ="xml/MyData.xml";
	grid1.ReloadBody(); 
}
function loadXML(){
	var grid1=Grids["g1"];
	grid1.Source.Data.Url ="test?arg=xml";
	grid1.ReloadBody(); 
}

function loadJSON(){
	var grid1=Grids["g1"];
	grid1.Source.Data.Url ="test?arg=json";
	grid1.ReloadBody(); 
}
function saveAsXML(){
	var grid1=Grids["g1"];
	grid1.Source.Upload.Url = "upload?arg=xml";
	grid1.Source.Upload.Type = "Data";
	grid1.Source.Upload.Xml = 1;
	grid1.Save(); 
}
function saveAsJSON(){
	var grid1=Grids["g1"];
	grid1.Source.Upload.Url ="upload?arg=json";
	grid1.Source.Upload.Type ="Data";
	grid1.Source.Upload.Format  ="JSON";
	grid1.Save(); 
}

</script>
</html>